<template>
	<!-- 订单详细 -->
	<view v-if="pageShow">
		<view class="all margin_top">
			<view class="xiaohuang" style="font-size: 32rpx;font-weight: bold;" v-show="dataAll.status==10">待审核</view>
			<view class="xiaohuang" style="font-size: 32rpx;font-weight: bold;"  v-show="dataAll.status==20">待出库</view>
			<view class="xiaohuang" style="font-size: 32rpx;font-weight: bold;"  v-show="dataAll.status==30">待发货</view>
			<view class="xiaohuang" style="font-size: 32rpx;font-weight: bold;"  v-show="dataAll.status==40">待收货</view>
			<view class="xiaolv" style="font-size: 32rpx;font-weight: bold;"  v-show="dataAll.status==50">已完成</view>
			<view class="xiaohong" style="font-size: 32rpx;font-weight: bold;"  v-show="dataAll.status==60">已作废</view>
			<view class="xiaohong" style="font-size: 32rpx;font-weight: bold;"  v-show="dataAll.status==70">已拒绝</view>
			<view class="flexleft margin_top" v-for="ite in dataAll.ordergoods" :key="ite.id" @click="getCommodityDetail(ite.goods_id)">
				<image :src="ite.goods_info.image_text" mode="" class="leftListimg margin_right"></image>
				<view class="flexcolumn">
					<view class="titletext hei_text xiankuan">{{ite.goods_info.name}}</view>
					<!-- <view class="xiaohuang">积分：230</view> -->
					<view class="hei_text strongtext" v-show="ite.difference_type==1">
						规格:{{ite.goods_info.biggoodsunit.name}}</view>
					<view class="hei_text strongtext" v-show="ite.difference_type==2">
						规格:{{ite.goods_info.middlegoodsunit.name}}</view>
					<view class="hei_text strongtext" v-show="ite.difference_type==3">
						规格:{{ite.goods_info.smallgoodsunit.name}}</view>
					<view class="flexbetween" style="width:100%">
						<view class="xiaohong">*{{ite.num}}</view>
						<view class="xiaohuang" v-show="dataAll.order_type==1">￥{{ite.total_price}}</view>
						<view class="xiaohuang" v-show="dataAll.order_type==2">{{ite.total_payscore}}分</view>
					</view>
				</view>
			</view>
			<view class="money">
				<view class="item">
					<view class="price order">订单号：{{dataAll.order_no}}</view>
					<view class="price">
						<image src="../../../static/order_copy.png" mode="" @click="copy(dataAll.order_no)"></image>
					</view>
				</view>
			</view>
			<view class="mainpadding_top ffffff radius" v-if="dataAll.notes">
				<view class="title">备注信息</view>
				<view class="price margin_top">{{dataAll.notes}}</view>
			</view>
			<view class="money" >
				<view class="item">
					<view class="title">订货数量</view>
					<view class="price">{{dataAll.x_goods_num}}</view>
				</view>
				<template v-if="dataAll.order_type==1">
					<view class="item">
						<view class="title">赠送积分</view>
						<view class="price">{{dataAll.x_total_score}}分</view>
					</view>
					<view class="item">
						<view class="title">总金额</view>
						<view class="price color">￥{{dataAll.x_total_price}}</view>
					</view>
					<view class="item">
						<view class="title">优惠金额</view>
						<view class="price color">￥{{dataAll.discount_price}}</view>
					</view>
				</template>
				<template v-if="dataAll.order_type==2">
					<view class="item">
						<view class="title">支付积分</view>
						<view class="price color">{{dataAll.x_total_payscore}}分</view>
					</view>
				</template>
				<view class="item">
					<view class="title">创建时间</view>
					<view class="price">{{dataAll.createtime_text}}</view>
				</view>
			</view>
			<view class="person radius">
				<!-- <view class="orderNumber">
					<view class="order">客户名称</view>
					<view class="Number no">{{dataAll.custom.name}}</view>
				</view> -->
				<view class="orderNumber publc">
					<view class="order">经办人</view>
					<view class="Number no flexright" @click="calldriver(dataAll.staff.mobile)">{{dataAll.staff.username}}
					<u-icon name="phone" color="#ffa126" size="20"></u-icon>
					</view>
				</view>
				<view class="orderNumber publc" v-if="dataAll.sendstaff.id">
					<view class="order">配送员</view>
					<view class="Number no flexright" @click="calldriver(dataAll.sendstaff.mobile)">{{dataAll.sendstaff.username}}
						<u-icon name="phone" color="#ffa126" size="20"></u-icon>
					</view>
				</view>
			</view>
			<view class="person radius" v-if="dataAll.custom_image_text">
				<view class="orderNumber publc">
					<view class="order">客户签名</view>
				</view>
				<image :src="dataAll.custom_image_text" style="width: 100%;" mode="widthFix"></image>
			</view>
			<view class="btn" v-if="Number(dataAll.arrears_price) && dataAll.status!=60 && dataAll.status!=70" @click="payorder()">支付</view>
			<view class="btn2"  v-if="dataAll.status==10" @click.stop="canceorder()">取消订单</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/commonFun/httpRequest.js");
	export default {
		data() {
			return {
				ordernum:'',  //订单号
				dataAll:{},   //订单数据
				listid:"",
				pageShow:false
			};
		},
		onLoad(options) {
			this.listid = options.id;
			
		},
		onShow() {
			this.orderdetail();
		},
		methods: {
			getCommodityDetail(i) {
				uni.navigateTo({
					url: '/pages/index/commodityDetail/commodityDetail?id=' + i,
				});
			},
			orderdetail(){
				let _this = this;
				httpRequest.request('/customapi/Saleorder/detail','POST',{
					id:this.listid,
				}).then(res => {
					_this.dataAll = res.data;
					this.pageShow = true
				})
			},
			// 支付订单
			payorder() {
				let data = {
					id:this.listid,
					x_total_price: this.dataAll.x_total_price
				}
				uni.navigateTo({
					url: "/pages/shoppingCart/pay?data=" + encodeURIComponent(JSON.stringify(data))
				})
			},
			//取消订单
			canceorder() {
				httpRequest.modal('提示', '确定取消订单吗？', true, (res) => {
					if (res) {
						httpRequest.request('/customapi/saleorder/applySaleOrder', 'POST', {
							id:this.listid
						}).then(res => {
							httpRequest.toast(res.msg)
							setTimeout(()=>{
								uni.navigateBack(1)
							},500)
						})
					}
				})
			},
			calldriver(num){
				uni.makePhoneCall({
					phoneNumber:num.toString(),//电话号码
					success:function(e){
						console.log(e);
					},
					fail:function(e){
						console.log(e);
					},
				})
			},
			copy(i){
				console.log(i,888);
				uni.setClipboardData({
					data:i,
					success() {
						httpRequest.toast("复制成功")
					},fail(err) {
						console.log(err,988);
					}
				})
			},
			
		}
	};
</script>

<style scoped lang="scss">
	.flexcolumn {
		display: flex;
		justify-content: space-between;
		flex-direction: column;
		align-items: flex-start;
		height: 180rpx;
		width: 100%;
	}
	
	.leftListimg {
		min-width: 180rpx;
		min-height: 180rpx;
		max-width: 180rpx;
		max-height: 180rpx;
		border-radius: 10rpx;
	}
	.anyone2 {
		display: flex;
		justify-content: space-between;
		margin-top: 20rpx;
		font-size: 30rpx;
		font-weight: 800;
		font-family: PingFang SC;
	
		.anyone2Left {
			color: #333333;
		}
	
		.anyone2Right {
			image {
				width: 12rpx;
				height: 20rpx;
				margin-left: 20rpx;
			}
		}
	}
	.strongtext{
		margin-top: 20rpx;
		font-size: 28rpx;font-weight: bold;
		color: #f5ab4f;
	}
	.all{
		padding: 0 40rpx;
	}
	.btn{
		margin-top: 30rpx;
		text-align: center;
		padding: 29rpx 0;
		font-size: 36rpx;
		font-family: PingFang SC;
		font-weight: 800;
		color: #FFFFFF;
		border-radius: 50rpx;
		background-color: #F5AC4F;
	}
	.btn2{
		margin-top: 30rpx;
		text-align: center;
		padding: 29rpx 0;
		font-size: 36rpx;
		font-family: PingFang SC;
		font-weight: 800;
		color: #F5AC4F;
		border-radius: 50rpx;
		background-color: #FFFFFF;
	}
	.no{
		font-size: 32rpx !important;
		font-family: PingFang SC;
		font-weight: 500;
		color: #999999 !important;
		align-items: center;
	}
	.publc{
		margin-top: 0 !important;
	}
	.color{
		font-size: 32rpx !important;
		font-family: PingFang SC;
		font-weight: 800;
		color: #FF0000 !important;
	}
	.person{
		background-color: #ffffff;
		.orderNumber{
			margin-top: 20rpx;
			padding: 28rpx;
			font-size: 32rpx;
			font-family: PingFang SC;
			font-weight: 800;
			color: #000000;
			display: flex;
			justify-content: space-between;
			.Number{
				image{
					width: 26rpx;
					height: 26rpx;
					margin-left: 10rpx;
				}
			}
		}
	}
	.item{
		padding: 30rpx;
		font-size: 32rpx;
		font-family: PingFang SC;
		color: #000000;
		display: flex;
		justify-content: space-between;
		.order{
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
		}
		.price{
			image{
				width: 30rpx;
				height: 30rpx;
			}
		}
	}
	.money{
		margin: 30rpx auto;
		border-radius: 20rpx;
		background-color: #ffffff;
		
	}
.detail {
	padding: 30rpx;
	background-color: #ffffff;

	.z1 {
		margin-top: 20rpx;
		display: flex;
		justify-content: space-between;
	}
	.bottom {
		margin-top: 20rpx;
		font-size: 32rpx;
		font-family: PingFang SC;
		font-weight: 800;
		color: #999999;
	}
	.detaiRight {
		flex-direction: column;
		display: flex;
		justify-content: space-between;
		flex-grow: 1;
		.top {
			.t1 {
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: 800;
				color: #333333;
				.font1 {
					overflow: hidden;
					text-overflow: ellipsis;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 2;
					.font2 {
						display: inline-block;
					}
				}
			}
			.t2 {
				display: flex;
				.left {
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: 800;
					color: #999999;
				}
				.center {
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: 800;
					color: #ffffff;
					background-color: #f5ac4f;
					margin: 0 10rpx;
					border-radius: 4px;
				}
				.right {
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #333333;
				}
			}
		}
		.bottom {
			display: flex;
			justify-content: space-between;
			font-size: 32rpx;
			.b1 {
			}
			.b2 {
				color: #ff0000;
			}
		}
	}
	.detailLeft {
		border-radius: 8px;
		margin-right: 20rpx;
		position: relative;
		overflow: hidden;
		flex-shrink: 0;
		.d1 {
			position: absolute;
			top: 0;
			left: 0;
			padding: 10rpx 20rpx;
			background-color: #ff0000;
			color: #ffffff;
			font-size: 28rpx;
			border-radius: 8px;
		}
		image {
			width: 252rpx;
			height: 209rpx;
			flex-shrink: 0;
		}
	}
}
.all {
	color: #333333;
}
.zsremark{
	margin-top: 10rpx;
	font-size: 28rpx;
	color: #333;
}
</style>
